package com.sh.data.engine.common.enumDefinition;

import com.google.common.collect.Lists;

import java.util.List;

/**
 * @author: zigui.zdf
 * @description:
 * @date: 2021/6/29 11:34
 */
public enum FlinkNodeIconEnum {
    FLINK_SQL_TASK(
        "iconFlinkSQLrenwu", Lists.newArrayList(FlinkNodeTypeEnum.TASK_SQL.getCode())),
    FLINK_TASK("iconFlinKrenwu", Lists.newArrayList(FlinkNodeTypeEnum.TASK_JAR.getCode())),
    //  FLINK_DATA_SYNC(
//      "iconshujucaiji", Lists.newArrayList(FlinkNodeTypeEnum.FLINK_DATA_SYNC_TASK.getCode())),
    RESOURCE("iconziyuan1", Lists.newArrayList(FlinkNodeTypeEnum.RESOURCE.getCode())),
    FUNCTION(
        "iconhanshu1",
        Lists.newArrayList(
            FlinkNodeTypeEnum.FUNCTION.getCode()/*,
          FlinkNodeTypeEnum.UDAF_FUNCTION.getCode(),
          FlinkNodeTypeEnum.UDTF_FUNCTION.getCode()*/));

    private String icon;

    private List<Integer> nodeTypes;

    FlinkNodeIconEnum(String icon, List<Integer> nodeTypes) {
        this.icon = icon;
        this.nodeTypes = nodeTypes;
    }

    public static String getIconByNodeType(Integer nodeType) {
        if (null == nodeType) {
            return null;
        }

        for (FlinkNodeIconEnum value : FlinkNodeIconEnum.values()) {
            final List<Integer> nodeTypes = value.nodeTypes;
            if (nodeTypes.contains(nodeType)) {
                return value.icon;
            }
        }
        return null;
    }
}
